package 第二讲数据结构;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class AcWing3302 {
	
	public static void eval(Deque<Integer> num,Deque<Character> op) {
		int num1=num.pop();
		int num2=num.pop();
		char x=op.pop();
		if(x=='*')num.push(num2*num1);
		else if(x=='/') num.push(num2/num1);
		else if(x=='+') num.push(num2+num1);
		else if(x=='-')num.push(num2-num1);
	}

	public static void main(String[] args) {
		Deque<Integer> num=new ArrayDeque<>();
		Deque<Character> op=new ArrayDeque<>();
		Map<Character, Integer> table=new HashMap<>();
		table.put('+',1);
		table.put('-', 1);
		table.put('*', 2);
		table.put('/', 2);
		 Scanner sc =new Scanner(System.in);
		 String s=sc.next();
		 int len=s.length();
		 for(int i=0;i<s.length();i++) {
			 char c=s.charAt(i);
			 if(Character.isDigit(c)) {
				 int x=0,j=i;
				 while(j<len&&Character.isDigit(s.charAt(j))) {
					 x=x*10+s.charAt(j)-'0';
					 j++;				 
				 }
				 num.push(x);
				 i=j-1;
			 }else if(s.charAt(i)=='(') {
				 op.push(s.charAt(i));
			 }else if(s.charAt(i)==')') {
				 while(op.peek()!='(') {
					 eval(num, op);
				 }
				 op.pop();
			 }else if(op.isEmpty()) {
				 op.push(s.charAt(i));
			 }else {
				 while(!op.isEmpty()&&op.peek()!='('&&table.get(op.peek())>=table.get(s.charAt(i))) {
					 eval(num, op);
				 }
				 op.push(s.charAt(i));
			 }
		 }
		 sc.close();
		 while(op.size()>0)eval(num, op);
		 System.out.print(num.peek());
		
	}

}
